package com.lyuewei.ringtone;

import android.app.Application;
import android.os.Build;

import androidx.core.os.BuildCompat;
import androidx.room.Room;

import com.elvishew.xlog.BuildConfig;
import com.elvishew.xlog.LogConfiguration;
import com.elvishew.xlog.XLog;
import com.lyuewei.ringtone.data.AppDatabase;
import com.lyuewei.ringtone.data.AppDatabaseCallback;
import com.lyuewei.ringtone.data.RingerSetting;


public class MyApplication extends Application {
    private static AppDatabase database; // 数据库实例

    public static AppDatabase getDatabase() {
        return database;
    }

    @Override
    public void onCreate() {
        super.onCreate();
            LogConfiguration config = new LogConfiguration.Builder()
                    //.tag("HEFA")
                    .enableStackTrace(1).enableThreadInfo()
                    .build();
            XLog.init(config);
        // 初始化 Room 数据库
        database = Room.databaseBuilder(
                        getApplicationContext(),
                        AppDatabase.class,
                        "ringer-database" // 数据库文件名
                )
                .addCallback(new AppDatabaseCallback()) .build();
    }
}